home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Screensavers 98
/
Screensavers 98.iso
/
scr
/
pyro
/
fclasses.h
< prev
next >
Wrap
C/C++ Source or Header
|
2000-03-28
|
8KB
|
191 lines
#include <windows.h>
#include <stdlib.h>
#include <time.h>
// **** Fire work constants ****
const int Fixed = 10; // Used in fixed point calculations.
extern int MAXX, MAXY;
extern int PixelSize;
// used int flare trailer to save previous points in a queue structure
struct SaveXY
{
int x, y;
};
// ******* N.B. Fixed point addition can be optiomised *********
class Flare
{
private:
int xPos, yPos; // start position of firework.
int ground, cycles; // ground limit, and cycles of life for flare.
int xPlot, yPlot; // X, Y increments for firework (fixed point).
int gravConst, gravty, thrust; // gravity pull on flare, virtical thrust on gravity, horizontal thrust
SaveXY* trailer; // point to trailer queue structure
int trailLen, bufPnt; // current size of trailer, current point in trailer element.
COLORREF colour; // current colour of flare.
BOOL overBuf, alive; // over write trailer buffer, and determine in flare is still active.
BOOL gndTerminated; // Test flare has hit the ground, if so then don't update x, y movement!
protected:
// Removes a point from the display, also adjust flooring of flare if
// it's below the floor limit.
void removePoint (HDC hdc, int x, int y);
// Displays a point from the display, also adjust flooring of flare if
// it's below the floor limit.
void showPoint (HDC hdc, int x, int y);
public:
// ********* Constructors **********
Flare (void);
Flare (int x, int y,
int thr = (1 * Fixed), int grav = (50 * Fixed),
int cyc = 20, int gnd = MAXY,
int trailLength = 5, COLORREF col = RGB(255,255,255));
// Setup a flare.
// x, y : Start location on the screen.
// thr : Horizontal pull of flare.
// gnd : Virtual pull of flare.
// cyc : Number of iterations of life (total life = cyc+trailLength).
// gnd : Set floor limit.
// trailLength: Length of flare trail.
// col : Set colour of flare.
void init (int x, int y,
int thr = (1 * Fixed), int grav = (50 * Fixed),
int cyc = 20, int gnd = MAXY,
int trailLength = 5, COLORREF col = RGB(255,255,255));
// This function will remove, move, and display a flare.
// hdc : handle to device context.
// returns true/false if flare is active.
BOOL move (HDC hdc);
// Change color of flare.
void setColour(COLORREF col)
{
colour = col;
}
// Get color of flare.
COLORREF getColour (void)
{
return colour;
}
int GetCycles (void)
{
return cycles;
}
// Returns the current position of the flare
void getCurrentPos (int& x, int& y)
{
x = xPos + (xPlot / Fixed);
y = yPos - (yPlot / Fixed);
}
// ********* Destructor **********
virtual ~Flare (void);
};
class SkyRocket
{
private:
Flare mainRocket; // Main rocket object fire into the sky/screen
Flare* pStarBurst; // Pointer to an array of flare objects.
BOOL explode; // Variable used to determine if updating main rocket or explosion.
int starBurstNum; // Num of flares in explosion.
int trailLen; // Trailer len of explosions
COLORREF colour; // Colour sky rocket.
// Variables used to calculate the colour change during the
// life of flare!
int colItemChange; // R, G, B value to change
int colChangeAmnt; // Positive/Negative amount to change.
public:
// **** constructor ****
SkyRocket ()
{
starBurstNum = 0;
pStarBurst = NULL;
explode = FALSE;
}
// Setup a skyrocket.
// starBNum: Number of objects in explosion.
// x, y : Start location on the screen.
// thr : Horizontal pull of flare.
// gnd : Virtual pull of flare.
// cyc : Number of iterations of life (total life = cyc+trailLength).
// gnd : Set floor limit.
// trailLength: Length of flare trail.
// col : Set colour of flare.
void init (int starBNum,
int x, int y,
int thr = (1 * Fixed), int grav = (50 * Fixed),
int cyc = 20, int gnd = MAXY,
int trailLength = 5, COLORREF col = RGB(255,255,255));
// This function will remove, move, and display a flare.
// hdc : handle to device context.
// returns true/false if flare is active.
BOOL move (HDC hdc);
// **** Destructor ****
~SkyRocket()
{
delete pStarBurst;
}
};
class FlowerPot
{
private:
Flare* pFlares; // Point to flare object list.
int flareNum; // Flare number to allocate.
COLORREF colour; // Inital colour of flares.
int cycles; // Cycles of life for flower pot.
int xPos, yPos; // Inital x, y, pos of flower pot
int trailLen; // Trailer length variable.
// Variables used to calculate the colour change during the
// life of flare!
int colItemChange; // R, G, B value to change
int colChangeAmnt; // Positive/Negative amount to change.
public:
// **** constructor ****
FlowerPot ()
{
pFlares = NULL;
xPos = yPos = cycles = colour = flareNum = 0;
}
// Initalise the flower pot.
// num : Number of flares to display.
// x,y : Start position of flower pot.
// col : Colour of flower pot.
// cyc : How long flower pot will live.
// tLen : Trailer length
void init (int num, int x, int y, COLORREF col, int cyc, int tLen);
// This function will remove, update, and display a flower pot.
// hdc : handle to device context.
// returns true/false if flare is active.
BOOL move (HDC hdc);
// **** Destructor ****
~FlowerPot()
{
delete pFlares;
}
};